package com.idudiao.sc.stream.controller;

import com.idudiao.sc.common.core.util.ScIdWorker;
import com.idudiao.sc.stream.mq.TestSender;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: 读钓
 * @date 2018-11-30 23:00
 */
@RestController
@Slf4j
public class TestController {
    @Autowired
    TestSender testSender;

    @RequestMapping("/sent")
    public void testOne(String message) {
        // 生成批次号
        String batchNo = ScIdWorker.getIdStr();
        testSender.output().send(MessageBuilder
                .withPayload(message)
                .setHeader("batchNo", batchNo)
                .build());
        log.info("【sc-consumer】[batchNo]={}, 发送消息：{}", batchNo, message);
    }
}